//@charset "utf-8"
var hqQuote = {
	request : async function (callback, mStock, period, dStock) {
		//ZHANGSHU
		var dataType = ['ZQMC', 'NEW', 'ZHANGDIEFU', '3934664', 'HUANSHOU','HIGH','LOW','PRE'];
		try {
			var thsQuote = new ThsQuote();

		} catch(e) {
			alert('需要客户端环境');
			return false;
		}

		dataType = dataType.join(',');
		var reqObj = {
			code: mStock,
			type: dataType,
			period: period,
			onready: async function() {
				var result = {};
				dataType = dataType.split(',');
				for (var type in dataType) {
					if (isNaN(type)) {
						continue;
					}
					var ret = null;
					if (dataType[type] == '3934664') {
						ret = {
								code : mStock,
								type : dataType[type],
								mode: 'beforecalclastfromsvrnow1st'
							};
					} else {
						ret = {code : mStock, type : dataType[type]};
					}

					try {
						var data = await thsQuote.getData(ret);
						data = eval(data);
						for (var i in data) {
							if (undefined == result[i]) {
								result[i] = {};
							}
							if ('zqmc' == ret.type || 'ZQMC' == ret.type) {
								result[i][ret.type] = data[i][ret.type];
								continue;
							}
							if (isNaN(data[i][ret.type])) {
								result[i][ret.type] = '--';
								continue;
							}
							result[i][ret.type] = data[i][ret.type];
						}
					} catch (exp) {
						continue;
					}
				}
				
				callback(result[dStock], dStock, mStock);
			}
		};

		await thsQuote.request(reqObj);
	}
}